//
//  AppTools.m
//  MemoryTravel
//
//  Created by dllo on 15/12/21.
//  Copyright © 2015年 fcx. All rights reserved.
//

#import "AppTools.h"

@implementation AppTools

#pragma mark -- get请求
+(void)getDataWithUrlStr:(NSString *)urlStr andBlock:(AppToolsBlock) appBlock {

    NSString *urlEncode = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];

    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    
    [manager.securityPolicy setAllowInvalidCertificates:YES];

    [manager GET:urlEncode parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        //block回调
        appBlock(responseObject);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

        NSLog(@"失败==== %@",error);
    }];
}

@end
